package com.zjkj.mp.controller.userManage;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zjkj.mp.service.user.UserService;
import com.zjkj.mp.utils.PaginatedResult;
import com.zjkj.mp.vo.user.USER_ZT;

/**
 * 
 * 黑名单控制器
 *
 * @author 陈晨
 * @history
 * <TABLE id="HistoryTable" border="1">
 * 	<TR><TD>时间</TD><TD>描述</TD><TD>作者</TD></TR>
 *	<TR><TD>2013-6-9</TD><TD>创建初始版本</TD><TD>陈晨</TD></TR>
 * </TABLE>
 */
@Controller
public class BlackListController {
	private static final int PAGE_SIZE = 10;

	@Resource(name = "userServiceImpl")
	private UserService userService;

	 /**
	  * 显示黑名单列表
	  */
	@RequestMapping("/showBlackList.do")
	public String showBlackList(HttpServletRequest req){
		String pageNoStr = req.getParameter("pageNo");
		int pageNo = 1;
		if(pageNoStr != null){
			pageNo = Integer.parseInt(pageNoStr);
		}
		
		Map<String,Object> params = new HashMap<String, Object>();
		params.put("userState", USER_ZT.JYZ);
		PaginatedResult result = this.userService.getUserList(pageNo, PAGE_SIZE,params);
		
		req.setAttribute("result", result);		
		return "user/blackList";
	}
	
	/**
	 * 将用户从黑名单中移除
	 */
	@RequestMapping("/removeFromBalckList.do")
	public String removeFromBalckList(HttpServletRequest req){
		String userId = req.getParameter("userId");
		this.userService.removeFromBalckList(Integer.parseInt(userId));
		
		//返回列表
		return showBlackList(req);
	}

}
